<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %> 
<%@ taglib uri="/WEB-INF/tld/ui.tld" prefix="ui" %> 
<%String path = request.getContextPath() ;%>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<jsp:include page="../../import.jsp" flush="true" />
</head>
<body class="iframeBody">
<div class="Wrapper">
<div>
<div id="pageInTab" class="pageInTab">
	<!-- 页签1-->
	<div tabid="tabA" lselected="true">
		<div class="searchArea">
			<!-- 搜索表单开始 -->
			<form id="searchBar">
				<div class="fieldset1 clearFix">
					<div class="FXBR">
						<div class="fieldBox">
							<div class="label">资料名称</div>
							<div class="field">
								<input type="text" id="warrantName" name="warrantName" class="ui-textbox" ligerui="width: 160" value="">
							</div>
						</div>
						<div class="fieldBox col_33">
							<div class="label">权证类别</div>
							<div class="field">
								<select id="warrantType"  name="warrantType"  ligerui="width: 160">
									<option value="">请选择</option>
									<c:forEach items="${warrantTypeList}" var="item">
										<option value="${item.key}">${item.value}</option>
									</c:forEach>
								</select>
							</div>
						</div>
						<div class="fieldBox">
							<div class="label">状态</div>
							<div class="field">
								<select id="isValid"  name="isValid"  ligerui="width: 160">
									<option value="">请选择</option>
									<option value="1">启用</option>
									<option value="0">废弃</option>
								</select>
							</div>
						</div>
						<div class="fieldBox">
							<div class="label">电子资料配置编号</div>
							<div class="field">
								<select id="cfgCd"  name="cfgCd"  ligerui="width: 160">
									<option value="">请选择</option>
									<c:forEach items="${cfgCdList}" var="item">
										<c:choose>
										   <c:when test="${item.CFG_CD == 'PRJ001'}">    
										   		<option value="${item.CFG_CD}">重卡项目合同</option>
										   </c:when>
										   <c:when test="${item.CFG_CD == 'PRJ002'}">    
										   		<option value="${item.CFG_CD}">汽车金融项目合同</option>
										   </c:when>
										   <c:otherwise>  
												<option value="${item.CFG_CD}">${item.CFG_NM}</option>
										   </c:otherwise>
										</c:choose>
									</c:forEach>
								</select>
							</div>
						</div>
						<div class="fieldBox col_33">
							<div class="label">电子资料配置子编号</div>
							<div class="field">
								<input id="cfgDtlCd" name="cfgDtlCd" data-value=" " placeholder="--请选择--" ltype="combobox" >
							</div>
						</div>
					</div>
					
					<div class="clearFix"></div>
					
					<!-- 表单按钮 -->
					<div class="btnsBox formBtns notRight">
						<span id="searchBtn" class="sq-button-round">查询</span>
						<span id="clearBtn" class="sq-button-round">清空</span>
						<input id="resetBtn" type="reset" value="重置" class="l-button l-button-reset Hide"/>
						<span id="addBtn" class="sq-button-round" onclick="save('');">新增</span>
		            </div>
		            
				</div>
			</form>
			<!-- 搜索表单结束 -->
		</div>
		<!-- 列表显示块 -->
		<div id="ligergrid1" class="sq-grid"></div>
	</div>
	
</div>
</div>
</div>
<script type="text/javascript">
	var pageInApp={
		flag:false //tab页验证关闭
	};//to下一级子窗口 接口
	var pageInTab=null;//页签
	var loadedTabs=[];//页签
	var grid = null;
	
	$(function () {
		$("#searchBar").ligerForm();//初始化表单
	    initGrid();//初始化列表
	    searchBtnEvent();//查询按钮事件
	    clearBtnEvent();//清空按钮事件
	    
	    $("#cfgDtlCd").ligerComboBox({
			valueField: 'cfgDtlCd',
			textField: 'contNm',
			width:150
		});
		
		$("#cfgCd").change(function(){
			setCfgDtlCd(this);
		});
		
		//触发change事件
		$("#cfgCd").trigger("change");
	});
	
	function setCfgDtlCd(obj){
		if($("#cfgCd").val() == "") {
			liger.get("cfgCd").clear();
			liger.get("cfgCd").setData({});
		}else {
			 $.ajax({
				type: 'post',
				dataType:'json',
				data:{code:$("#cfgCd").val()},
				url: '<%=path%>/archive/arcBscInfo/selectCfgDtlCdList.do',
				success:function(msg){
					 if(msg.success == 1){
						 var obj = liger.get("cfgDtlCd");
						 if(msg.data){
							 /* var item = {cfgDtlCd:"", contNm:"请选择222"};
							 msg.data.push(item); */
							 obj.setData(msg.data);//设置下拉选项
						 }else{
							 obj.clear();
							 obj.setData({});
						 }
					 }else{
						 $.ligerDialog.SQalert({content:msg.info, SQ_type: "error"});
					 }
				}
			}); 
		}
	}
	
	//查询参数
	function getSearchParams(){
		var form = new liger.get("searchBar");
		var data = form.getData();
		return data;
	}
	
	//初始化列表
	function initGrid(){
		$("#ligergrid1").ligerGrid({
			url:'<%=path%>/archive/arcBscInfo/initList.do',
			method:'get',
			parms:getSearchParams(),
			columns:[
				{ display: '资料名称', name: 'warrantName',  align:'center', enabledSort:true,width:300,
						render:function (rowdata, rowindex, value){
							return "<span title="+rowdata.warrantName+">"+rowdata.warrantName+"</span>";
						}},
				{ display: '权证类别', name: 'warrantTypeNm', align:'center', enabledSort:true},
				{ display: '是否电子', name: 'isEle', align:'center', enabledSort:true,
					render:function (rowdata, rowindex, value){
							return (value == "yes")?"是":"否";
					}
				},
				{ display: '电子资料配置编号', name: 'cfgCdNm', align:'center', enabledSort:true},
				{ display: '电子资料配置子编号', name: 'cfgDtlCdNm', align:'center', enabledSort:true},
				{ display: '状态', name: 'isValid', align:'center', enabledSort:true,
					render:function (rowdata, rowindex, value){
							return (value == "1")?"启用":"废弃";
					}
				},
				//{ display: '归类级别', name: 'arcLevelNm', align:'center', enabledSort:true},
				{display:'操作',
				isSort:false,
				align:'center',
				render:function (rowdata, rowindex, value){
					var h="";
		            	h+='<a class="sq-button-hasicon" href="javascript:save(';
		                h+="'"+rowdata.id+"'";
		                h+=")\"><i class='sqBtnIco_4'></i>修改</a>";
					
		                h+='<a class="sq-button-hasicon" href="javascript:removeById(';
		                h+="'"+rowdata.id+"'";
		                h+=")\"><i class='sqBtnIco_4'></i>删除</a>";
		                
					return h;
				}
			}
			],
			pageSize:10,
			root:'rows',
			record:'total',
			hideLoadButton:false,
			width:'100%',
			height:'100%',
			heightDiff:-2,
			//checkbox:true,//列表是否有选择框
			rownumbers:true,//列表是否有行号
			//选择行事件
			onSelectRow: function(rowdata, rowid, rowobj){
				
			},
			//取消选择行事件
			onUnSelectRow : function(rowdata, rowid, rowobj){
				
			}
		});
		grid = liger.get("ligergrid1");
		grid.setHeight(100);
		//grid.options.isSingleCheck = false;//列表是否为单选
	}
	
	//发起申请
	function warrantFileManageApply(paySchId,paySchNo,prjPrdDtlId,prjId,businessType,prjTypCd,prjNm,orgName,cstId,cstNm){
		//回调刷新列表
		var param = '<%=path%>/warrant/warrantfilemanage/toApplyPage.do?paySchId=' + paySchId + '&&paySchNo=' + paySchNo +'&&prjPrdDtlId='+prjPrdDtlId+'&&prjId='+prjId+'&&businessType='+businessType;
		param += '&&prjTypCd='+prjTypCd+'&&prjNm='+prjNm+'&&orgName='+orgName+'&&cstId='+cstId+'&&cstNm='+cstNm;
		
		Add_navTab('warrantFileManage'+paySchId,'归档申请',param, function () {
			grid.reload();
		});
	}
	
	
	//清空按钮事件
	function clearBtnEvent(){
		$("#clearBtn").click(function(event) {
			$("#resetBtn").click();  //重置 input-text
			var form = liger.get("searchBar");
			form.setData({  //重置select等特殊表单
				"warrantType":"",
				"isValid":""
			});
			
			liger.get("cfgCd").clear();
			liger.get("cfgDtlCd").clear();
			liger.get("cfgDtlCd").setData({});
		});
	}
	
	//查询按钮事件
	function searchBtnEvent(){
		$("#searchBtn").click(function(event) {
			var form = new liger.get("searchBar");
			var data = form.getData();
// 			alert(JSON.stringify(data));
			for (name in data){
				grid.setParm(name,data[name]);
			};
			grid.reload();
		});
	}
	
	
	
	//档案基础信息新增和修改
	function save(id) {
		var title ="修改";
		if(id == "") {
			title ="新增";
		}
		Add_navTab("arcBscInfo"+id, "基础档案资料"+title, '<%=path%>/archive/arcBscInfo/toSave.do?id='+id , function () {
			grid.reload();
		});
	}
	
	
	
	//删除
	function removeById(id) {
		
		$.ligerDialog.confirm('确定删除吗?', function (flag) {
			if(flag == false)return;
			var wait_dialog;
			$.ajax({
				type: 'post',
				dataType:'json',
				url: '<%=path%>/archive/arcBscInfo/removeById.do?id='+id,
				beforeSend: function(){
			          wait_dialog=$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING ,SQ_type: "waitting" });
			     },
				success:function(msg){
					wait_dialog.close();
					 if(msg.success == 1){
						 $.ligerDialog.SQalert({content:msg.info, SQ_type: "success"});
						 grid.reload();
					 }else{
						 $.ligerDialog.SQalert({content:msg.info, SQ_type: "error"});
					 }
				}
			});
		});
	}
	
	
	
	
</script>
</body>
</html>